Learn R Programming

haplotypes (version 1.1.3)

[-methods: Extract or replace parts of an object of class Dna

Description

Operators acting on sequence matrix to extract or replace parts.

Usage

# S4 method for Dna
[(x, i, j,as.matrix = TRUE, drop = FALSE)
# S4 method for Dna
[(x, i, j)<- value

Value

returns an object of class matrix, vector or Dna.

Arguments

x

an object of class Dna

i, j

elements to extract or replace.

as.matrix

boolean; If TRUE, function returns a matrix or a vector (if drop is TRUE), else, function returns an object of class Dna.

drop

boolean; if TRUE and a single row or column is selected, the function returns a vector instead of a matrix. This is only applicable when as.matrix is TRUE.

value

a character vector or a character matrix.

Methods

signature(x = "Dna", i = "ANY", j = "ANY", drop = "ANY")

Author

Caner Aktas, caktas.aca@gmail.com

See Also

Dna

Examples

Run this code

data("dna.obj")
x<-dna.obj

## Extract parts.
# a matrix object
x[1:2,1:3]

# a Dna object, as.dna(x[1:2,1:3]) gives the same result
x[1:2,1:3,as.matrix=FALSE] 

# a vector
x[1,1,drop=TRUE]

## Replace parts.
#"G" "C"
x[1,1:2] 	
x[1,1:2]<-c("A","T")
x[1,1:2]

Run the code above in your browser using DataLab